function fig = fm_sset()
% FM_SSET create GUI for UDM service variable settings
%
% HDL = FM_SSET()
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Version:   1.0.0
%
%E-mail:    federico.milano@ucd.ie
%Web-site:  faraday1.ucd.ie/psat.html
%
% Copyright (C) 2002-2019 Federico Milano

global Theme Fig Servc

if ishandle(Fig.sset), figure(Fig.sset), return, end

h0 = figure('Color',Theme.color01, ...
	    'Units', 'normalized', ...
	    'Colormap',[], ...
	    'CreateFcn','Fig.sset = gcf;', ...
	    'DeleteFcn','Fig.sset = -1;', ...
	    'FileName','fm_sset', ...
	    'MenuBar','none', ...
	    'Name','Service Variable Settings', ...
	    'NumberTitle','off', ...
	    'PaperPosition',[18 180 576 432], ...
	    'PaperType','A4', ...
	    'PaperUnits','points', ...
	    'Position',[0.4525   0.2802   0.2375   0.4395], ...
	    'ToolBar','none');

% Frame for parameters and settings
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'ForegroundColor',Theme.color03, ...
	       'Position',[0.1000   0.1738   0.8000   0.6600], ...
	       'Style','frame', ...
	       'Tag','Frame1');

% Popup Menus
h(1) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'ForegroundColor',Theme.color05, ...
		 'FontName',Theme.font01, ...
		 'HorizontalAlignment','left', ...
		 'Position',[0.5000   0.5671   0.3500   0.0444], ...
		 'Style','popupmenu', ...
		 'Tag','PopupMenu1', ...
		 'Value',1);
h(2) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'ForegroundColor',Theme.color05, ...
		 'FontName',Theme.font01, ...
		 'HorizontalAlignment','left', ...
		 'Position',[0.5000   0.6493   0.3500   0.0444], ...
		 'Style','popupmenu', ...
		 'Tag','PopupMenu2', ...
		 'Value',2);
h(3) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'ForegroundColor',Theme.color05, ...
		 'FontName',Theme.font01, ...
		 'HorizontalAlignment','left', ...
		 'Position',[0.5000   0.7315   0.3500   0.0444], ...
		 'String',{'Input';'Inner';'Output'}, ...
		 'Style','popupmenu', ...
		 'Tag','PopupMenu3', ...
		 'Value',2);
h(4) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'ForegroundColor',Theme.color05, ...
		 'FontName',Theme.font01, ...
		 'HorizontalAlignment','left', ...
		 'Position',[0.5000   0.4849   0.3500   0.0444], ...
		 'String',{'No';'Yes'}, ...
		 'Style','popupmenu', ...
		 'Tag','PopupMenu4', ...
		 'Value',1);

% Push buttons
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color03, ...
	       'Callback','fm_comp sset', ...
	       'FontWeight','bold', ...
	       'ForegroundColor',Theme.color09, ...
	       'Position',[0.1000   0.0543   0.2333   0.0761], ...
	       'String','Ok', ...
	       'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'Callback','fm_comp sset', ...
	       'Position',[0.3833   0.0543   0.2333   0.0761], ...
	       'String','Apply', ...
	       'Tag','Pushbutton2');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'Callback','close(gcf)', ...
	       'Position',[0.6666   0.0543   0.2333   0.0761], ...
	       'String','Cancel', ...
	       'Tag','Pushbutton3');

% Frame and edit text for the variable name
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color04, ...
	       'ForegroundColor',Theme.color03, ...
	       'Position',[0.1000   0.8696   0.8000   0.0652], ...
	       'Style','frame', ...
	       'Tag','Frame1');
h(8) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'FontWeight','bold', ...
		 'ForegroundColor',Theme.color07, ...
		 'Position',[0.2000   0.8750   0.6000   0.0435], ...
		 'Style','text', ...
		 'Tag','StaticText3');

% Static Texts
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'HorizontalAlignment','right', ...
	       'Position',[0.1500   0.7315   0.3250   0.0444], ...
	       'String','Type', ...
	       'Style','text', ...
	       'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'HorizontalAlignment','right', ...
	       'Position',[0.1500   0.6493   0.3250   0.0444], ...
	       'String','Superior Limit', ...
	       'Style','text', ...
	       'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'HorizontalAlignment','right', ...
	       'Position',[0.1500   0.5671   0.3250   0.0444], ...
	       'String','Inferior Limit', ...
	       'Style','text', ...
	       'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'HorizontalAlignment','right', ...
	       'Position',[0.1500   0.4849   0.3250   0.0444], ...
	       'String','Offset', ...
	       'Style','text', ...
	       'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'HorizontalAlignment','right', ...
	       'Position',[0.1500   0.4027   0.3250   0.0444], ...
	       'String','Matlab Name', ...
	       'Style','text', ...
	       'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'HorizontalAlignment','right', ...
	       'Position',[0.1500   0.3205   0.3250   0.0444], ...
	       'String','TeX Name', ...
	       'Style','text', ...
	       'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
	       'Units', 'normalized', ...
	       'BackgroundColor',Theme.color02, ...
	       'HorizontalAlignment','right', ...
	       'Position',[0.1500   0.2383   0.3250   0.0444], ...
	       'String','Initial Guess', ...
	       'Style','text', ...
	       'Tag','StaticText2');

% Edit texts
h(5) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'Callback','fval(gcbo,get(gcbo,''UserData''),0);', ...
		 'FontName',Theme.font01, ...
		 'ForegroundColor',Theme.color05, ...
		 'HorizontalAlignment','left', ...
		 'Position',[0.5000   0.2383   0.3500   0.0444], ...
		 'Style','edit', ...
		 'Tag','EditText1');
h(6) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'Enable','inactive', ...
		 'FontName',Theme.font01, ...
		 'ForegroundColor',Theme.color05, ...
		 'HorizontalAlignment','left', ...
		 'Position',[0.5000   0.4027   0.3500   0.0444], ...
		 'Style','edit', ...
		 'Tag','Edit_uname');
h(7) = uicontrol('Parent',h0, ...
		 'Units', 'normalized', ...
		 'BackgroundColor',Theme.color04, ...
		 'FontName',Theme.font01, ...
		 'ForegroundColor',Theme.color05, ...
		 'HorizontalAlignment','left', ...
		 'Position',[0.5000   0.3205   0.3500   0.0444], ...
		 'Style','edit', ...
		 'Tag','Edit_fname');

set(h0,'UserData',h)
if nargout > 0, fig = h0; end
